#pragma once
#include "..\nodes\SpriteNode.h"

namespace ds {

class SpriteCounter {

struct Number {
	SHandle handle;
	int counter;
	Vec2 pos;
	Vec2 scaling;
};

typedef std::vector<Number> Numbers;

public:
	SpriteCounter(SpriteNode* batchNode,const Rect& startOffset,int width,int digits);
	SpriteCounter(SpriteNode* batchNode,const Vec2& pos,const Rect& startOffset,int digits,const Color& color);
	~SpriteCounter();
	void setCounter(int cnt);
	void setPos(const Vec2& pos);
	void setColor(const Color& color);
	void setActive(bool active);
	void setScale(const Vec2& scale);
	int getCounter() const {
		return m_Value;
	}
private:
	void prepare(const Vec2& pos,const Rect& startOffset,int digits,const Color& color);
	Rect getOffset(int nr);
	SpriteNode *m_Sprites;
	Color m_Color;
	Numbers m_Numbers;
	Rect m_StartOffset;
	Vec2 m_Scale;
	Vec2 m_Position;
	int m_Width;
	int m_Height;
	int m_Digits;
	int m_Start;
	int m_Value;
};

}